package com.quick.DP.strategyMode;

public class StrategyPatternTest {
    public static void main(String[] args) {
        // 测试数据
        double amount = 1000.0;
        String[] levels = {"normal", "silver", "gold", "platinum"};
        
        // 原始if-else实现测试
        System.out.println("=== if-else实现 ===");
        DiscountService originalService = new DiscountService();
        for (String level : levels) {
            double result = originalService.calculateDiscount(level, amount);
            System.out.printf("会员等级: %s, 折后金额: %.2f%n", level, result);
        }
        
        // 策略模式实现测试
        System.out.println("\n=== 策略模式实现 ===");
        OptimizedDiscountService optimizedService = new OptimizedDiscountService();
        for (String level : levels) {
            double result = optimizedService.calculateDiscount(level, amount);
            System.out.printf("会员等级: %s, 折后金额: %.2f%n", level, result);
        }
        
        // 测试异常情况
        try {
            optimizedService.calculateDiscount("diamond", amount);
        } catch (IllegalArgumentException e) {
            System.out.println("\n异常测试: " + e.getMessage());
        }
    }
}